//    Copyright (C) Kherty.  All rights reserved.
using OpenLS.Core.Serialization;

namespace OpenLS.Drawing
{
    public class FontReference : IOfficeXmlSerializable
    {
        private ColorBase color;
        private FontCollectionIndex idx;

        public FontCollectionIndex Index
        {
            get { return idx; }
            set { idx = value; }
        }

        public ColorBase Color
        {
            get { return color; }
            set { color = value; }
        }

        #region IOfficeXmlSerializable Members

        void IOfficeXmlSerializable.ReadXml(ReadContext context)
        {
            using (var c = context.Read("fontRef"))
            {
                Index = c.GetEnum<FontCollectionIndex>("idx");
                Color = ColorBase.ReadOptionalColor(c);
            }
        }

        void IOfficeXmlSerializable.WriteXml(WriteContext context)
        {
            using (WriteContext c = context.Write("fontRef"))
            {
                c.SetEnum("idx", Index);
                c.WriteOptionalElement(Color);
            }
        }

        #endregion
    }
}